<?php
/*===========================================================================*
 * IAESTE Application System v2                                              *
 *---------------------------------------------------------------------------*
 * The system is developed for IAESTE Norway's Exchange. This is an          *
 * open-source system, that can be reused and published for they that want   *
 * the system.                                                               *
 * --------------------------------------------------------------------------*
 * @author: Teis Lindemark, <mail@teilin.net>                                *
 * @version: 0.0                                                             *
 * ==========================================================================*/

//Start session
session_start();

//Import libaries
require_once '../lib/PHPTAL.php';
require_once '../lib/basic.php';
require_once '../lib/database.php';
require_once '../etc/config.php';
require_once '../lib/apply.php';
require_once '../pages/login.php';
require_once '../lib/txtlocal.php';

$l = new login();
$sms = new txtlocal(1, 1, 'IAESTE');

$submit = null;
//Check GET
if(isset($_GET['submit'])) {
    $submit = $_GET['submit'];   
}

//Application structure
if(checkOpen()) {
    switch ($submit) {
        case 'fav':
            include_once '../pages/offers.php';
            break;
        case 'apply':
            include_once '../pages/apply.php';
            break;
        case 'offer':
            include_once '../pages/offer.php';
            break;
        case 'login':
            $l->login();
            break;
        case 'logout':
            $l->logout();
            break;
        case 'getloggedin':
            $l->main();
            break;
        case 'profile':
            include_once '../pages/profile.php';
            break;
        case 'register':
            include_once '../pages/register.php';
            break;
        case 'forgot':
            include_once '../pages/forgot.php';
            break;
        case 'info':
            include_once '../pages/info.php';
            break;
        case 'offers':
            include_once '../pages/offers.php';
            break;
        default:
            include_once '../pages/info.php';
            break;
    }
} else {
    include_once '../pages/closed.php';
}
?>